package com.swift.authority.application.config.security;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;

/**
 * 资源服务器：@EnableResourceServer
 * 获取资源步骤：
 *      1、获取授权码
 *      2、获取授权码以后 需要携带令牌
 *      3、通过授权码+令牌 就可以获取资源
 *
 * @author Administrator
 * @version 1.0
 * @description 资源服务器
 * @date 2022/07/02  15:03
 */
@Configuration
@EnableResourceServer
public class ResourceServerConfig  extends ResourceServerConfigurerAdapter {
    /**
     * 先拦截请求 authenticated() 再放行
     * @param http
     * @throws Exception
     */
    @Override
    public void configure(HttpSecurity http) throws Exception {
        http
                .authorizeRequests()
                .anyRequest()
                .authenticated()
                .and()
                .requestMatchers()
                .antMatchers("/users/**");
    }


}
